import request from '@/utils/request'
import store from '@/store'
function apiPrefix() {
  return 'auto/' + store.getters.dbKey + '/'
}
export default {
  search(table, page, query) {
    const url = apiPrefix() + table
    const params = query || {}
    params.page = page
    return request({
      url: url,
      method: 'GET',
      params: params
    })
  },
  create(table, data) {
    const url = apiPrefix() + table
    return request({
      url: url,
      method: 'PUT',
      data: { data }
    })
  },
  update(table, id, data) {
    const url = apiPrefix() + table + '/' + id
    return request({
      url: url,
      method: 'POST',
      data: { data }
    })
  },
  delete(table, id) {
    const url = apiPrefix() + table + '/' + id
    return request.delete(url)
  }
}
